package com.hsc.www.dealLetter;

import com.alibaba.fastjson.JSONObject;
import com.hsc.www.User;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class UserSender {
    @Autowired
    private RabbitTemplate template;


    public void send(String routingKey, User user) {
        Message message=  JSONObject.parseObject("{\"body\":\"rO0ABXNyABBjb20uaHNjLnd3dy5Vc2VyM79FLxSURCQCAAFMAARuYW1ldAASTGphdmEvbGFuZy9PYmplY3Q7eHB0AARkb2cw\",\"messageProperties\":{\"consumerQueue\":\"dogQueue\",\"consumerTag\":\"amq.ctag-guAD6yIKR3AxRUgfn0UK2w\",\"contentLength\":0,\"contentType\":\"application/x-java-serialized-object\",\"deliveryTag\":1,\"finalRetryForMessageWithNoId\":false,\"headers\":{},\"priority\":0,\"publishSequenceNumber\":0,\"receivedDeliveryMode\":\"PERSISTENT\",\"receivedExchange\":\"dogExchange\",\"receivedRoutingKey\":\"dogRoutingKey\",\"redelivered\":false}}"
            , Message.class);

        template.convertAndSend(Config.DOG_EXCHANGE, routingKey, message.toString());
        System.out.println("发送：" + message.toString());
    }
}